<!--
 * @Author: your name
 * @Date: 2021-12-09 19:59:23
 * @LastEditTime: 2021-12-09 20:40:36
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \12.9work\project\src\views\About.vue
-->
<template>

  <div class="about">
    <el-button  size="small">添加</el-button>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="id"
        >
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        >
      </el-table-column>
      <el-table-column
        prop="city"
        label="地址">
      </el-table-column>
      <el-table-column
        prop="title"
        label="描述">
      </el-table-column>
      <el-table-column
        prop="id"
        label="操作">
        <template >
        <el-button type="text" size="small">编辑</el-button>
      </template>
      </el-table-column>
      
    </el-table>
    <el-pagination
    layout="prev, pager, next"
    @current-change="handleCurrentChange"
    :total="total">
  </el-pagination>
  </div>
</template>
 <script>
    import axios from "axios"
    export default {
      data() {
        return {
          tableData: [],
          total:null,
          
        }
      },
      methods:{
        async getAndSet(pageIndex=1,pageSize=10){
          const resp=await axios('/api/getList',{
            params:{pageIndex,pageSize}
          })
          this.tableData=resp.data.newList,
          this.total=resp.data.total
        },
        handleCurrentChange(index){
          this.getAndSet(index)
        }
      },
      created(){
        this.getAndSet()
      }
    }
  </script>